<template>
  <bodyWrap :isShow="bodyShow" style="z-index: 99">
    <div slot="body" v-if="bodyShow">
      <searchWrap @inputValue="inputValue"></searchWrap>
      <ul class="contacts-ul" v-if="searchList.length">
        <li class="contacts-li"
            v-for="p in searchList">
          <img src="../../img/q.png" class="img-h">
          <input class="checkInput"
                 :value="p.linkdoodID"
                 type="radio"
                 v-model="checked">
          <div class="txtWrap">
            <div class="name">
              {{p.linkdoodName}}
            </div>
            <div class="checkIcon"></div>
          </div>
        </li>
      </ul>
    </div>
  </bodyWrap>
</template>

<script>
  import searchWrap from "./search.vue"
  export default {
    data() {
      return {
        bodyShow: false,
        checked: false,
        searchList: [],
        headerRightType: {},
        headerFlag: "",
        id: "",
      }
    },
    methods: {
      init() {
        let self = this;
        this.headerRightType = this.$store.state.headerRightType;
        this.headerFlag = this.$store.state.showFlag;
        let code = _methods.getUrlParam("code");
        _methods.headerTitleChange(111);
        _methods.headerRightShow(
          {
            val: 111,
            txt: "确定"
          }
        );
        window._methods.getPeoples(code, (p) => {
          _data.leaderList = p;
          this.searchList = _data.leaderList;
          self.bodyShow = true;
        });
      },
      inputValue(v) {
        let k = v.toString().trim();
        if (k != "") {
          this.searchList = _data.leaderList.filter((v) => {
            return v.linkdoodName.indexOf(k) != -1;
          });
        } else {
          this.searchList = _data.leaderList;
        }
      },
    },
    components: {
      searchWrap
    },
    created() {
      this.init();
    },
    mounted() {
      let self = this;
      _data.busInit.on_(() => {
        _data.processSubmitData.userIds = self.checked;
        if (_data.processSubmitData.userIds) {
          _methods.goBack();
          _data.bus.$emit('toLeader', 1);
        } else {
          mui.toast("请选择批示领导");
        }
      });
    },
    beforeDestroy() {
      _data.busInit.off_();
      _methods.headerTitleChange(this.headerFlag, true);
      _methods.headerRightShow(this.headerRightType);
    }
  }
</script>
